package com.example.test1.config;

import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//创建一个聊天记忆记录区,并指定大小
public class MemeryConfig {

        @Bean

        //@AiService(wiringMode = AiServiceWiringMode.EXPLICIT,
            //        chatModel = "qwenChatModel",
            //        chatMemory = "chatMemory")  //新-指定聊天记忆区
//方法名就是注解中的参数名:
        ChatMemory chatMemory() {
            //设置聊天记忆记录的message数量
            return MessageWindowChatMemory.withMaxMessages(10);
        }

        }
